package com.gemantic.task.service;

import java.util.Date;
import java.util.List;

import com.gemantic.task.config.task.TaskPriority;
import com.gemantic.task.dto.DbTaskJobParams;
import com.gemantic.task.dto.ResResult;
import com.gemantic.task.dto.TaskQueryReqDto;
import com.gemantic.task.dto.TaskQueryRespDto;
import com.gemantic.task.handler.BaseTaskHandler;
import com.gemantic.task.model.Task;

public interface TaskService {

    void closeTask(String orderNo, String taskType, String remark);

    void runTask(String runnerName);

    ResResult runTask(long taskId, String runnerName);

    List<Task> getOpenTaskByOrder(String orderNo, Class taskClass);


    Task getFirstOpenTaskByOrder(String orderNo, Class taskClass);

    List<Task> getOpenTaskByOrder(String orderNo, String taskType);

    List<Task> getAllTaskByOrder(String orderNo, String taskType);

    Task getFirstOpenTaskByOrder(String orderNo, String taskType);

    <T extends BaseTaskHandler> Task createTask(String orderNo, Class<T> taskClass, Object req, TaskPriority priority);

    <T extends BaseTaskHandler> Task createTask(String orderNo, Class<T> taskClass, Object req, TaskPriority priority,
                                                int maxRetryTimes);

    <T extends BaseTaskHandler> Task createTask(String orderNo,
                                                Class<T> taskClass,
                                                Object req,
                                                TaskPriority priority,
                                                Date nextRunDate);

    <T extends BaseTaskHandler> Task createTask(String orderNo,
                                                Class<T> taskClass,
                                                Object req,
                                                TaskPriority priority,
                                                Date nextRunDate,
                                                int maxRetryTimes);

    Task createTask(String orderNo, String taskType, Object req, TaskPriority priority);

    Task createTask(String orderNo, String taskType, Object req, TaskPriority priority, int maxRetryTimes);

    Task createTask(String orderNo, String taskType, Object req, TaskPriority priority, Date nextRunDate);

    Task createTask(String orderNo, String taskType, Object req, TaskPriority priority, Date nextRunDate, int maxRetryTimes);


    void runFromDb(DbTaskJobParams params);

    void batchUpdate(Date nextRunTime, String status, List<Long> tasks);

    TaskQueryRespDto getTasks(TaskQueryReqDto taskQueryReqDto);

    void modifyTaskFromUI(Task task);

    void runFromMq(DbTaskJobParams params);
}
